{% extends 'df_goods/base.html' %}
{% load static %}
{% block head %}
    <script type="text/javascript" src="{% static 'js/jquery-1.12.4.min.js' %}"></script>
    <script type="text/javascript">
        $(function(){
            $(".add_goods").click(function(){
                url = 'http://127.0.0.1:8080/cart/add' + this.id + '_1'; // 列表页面只能添加1件商品
                $.get(url, function(data){
                    $("#show_count").text(data.count);
                });
            });
        });
    </script>
{% endblock head %}
{% block list %}
        <div class="r_wrap fr clearfix">
            <div class="sort_bar">
                <a href="/goods/list{{typeid}}_1_1" {% if sortdefault %} class="active" {% endif %}>默认</a>
                <a href="/goods/list{{typeid}}_1_2" {% if sortprice %} class="active" {% endif %}>价格</a>
                <a href="/goods/list{{typeid}}_1_3" {% if sortclick %} class="active" {% endif %}>人气</a>
            </div>

            <ul class="goods_type_list clearfix">
				{% for g in goodList %}
                <li>
                    <a href="/goods/{{g.id}}"><img src="{{STATIC_URL}}{{g.gpic}}"></a>
                    <h4><a href="/goods/{{g.id}}">{{g.gtitle}}</a></h4>
                    <div class="operate">
                        <span class="prize">{{g.gprice}}</span>
                        <span class="unit">{{g.gunit}}</span>
                        <a href="javascript:;" id="{{g.id}}" class="add_goods" title="加入购物车"></a>
                    </div>
                </li>
				{% endfor %}
            </ul>

				<div class="pagenation">
                {% if pageid > 1 %}
                <a href="/goods/list{{typeid}}_{{pageid|add:-1}}_{{sort}}">上一页</a>
                {% endif %}



                {% for pindex in pindexlist %}
                <a href="/goods/list{{typeid}}_{{pindex}}_{{sort}}" {% if pindex == pageid %} class="active" {% endif %}>{{pindex}}</a>
                {% endfor %}



                {% if pageid < pindexlist|length %}
                <a href="/goods/list{{typeid}}_{{pageid|add:1}}_{{sort}}">下一页</a>
                {% endif %}
            </div>
        </div>
{% endblock list %}